#include<bits/stdc++.h>
using namespace std;
int n,m,l,v,d[900001]={},u[900001]={},a[900001]={},p[900001]={},deract[900001]={},die=0,mashineuse[9000001]={},mx=-10000;//n the number of cars,m the number of machines,l how far the road is,v max speed,d the way to the ST,n 1st speed,a add speed
//decret canit change 0 yes,1 no,p machines' place
int tot=0;
int checkspeed(int fs,int as,int fp){
	for(int i=1;i<=m;i++){
		if(p[i]>fp){
			int ans=(fs*fs)+(2*as)*(p[i]-fp);
			if(v*v<ans){
				tot++;
				deract[p[i]]=1;
				return true;
			}
		}
	}
	return false;
}
int checkmashine(int fs,int as,int fp,int we){
	int t=0;
	for(int i=1;i<=m;i++){
		if(p[i]>fp){
			int ans=(fs*fs)+(2*as)*(p[i]-fp);
			if(v*v<ans){
				if(mashineuse[p[i]]==we-1){
				mashineuse[p[i]]++;
				t=1;
				continue;
			}
		}
	}
}
	if(t) return 0;
	die++;
	return 0;
}
void DIS(){
	die=0;
	int time=0;
	tot=0;
	d[900001]={};u[900001]={};a[900001]={};p[900001]={};deract[900001]={};
	cin>>n>>m>>l>>v;
	for(int i=1;i<=n;i++){
		cin>>d[i]>>u[i]>>a[i];
	}
	for(int i=1;i<=m;i++){
		cin>>p[i];
		deract[p[i]]=-1;
	}
	for(int i=1;i<=n;i++){
//		checkspeed(u[i],d[i],a[i]);
		if(checkspeed(u[i],a[i],d[i])){
			time++;
			checkmashine(u[i],a[i],d[i],time);
		}
	}
	cout<<tot<<" "<<m-die-1<<endl;
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T;
	cin>>T;
	while(T--){
		DIS();
	}
	return 0;
}
